/**
 * 
 */
package net.oov.identify.junit;

import java.io.IOException;
import java.io.StringReader;

import net.oov.identify.Buck;
import net.oov.identify.OI;
import net.oov.identify.SequenceFreqContainer;
import net.oov.identify.SequenceFreqContainerFactory;

import org.apache.lucene.analysis.TokenStream;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.wltea.analyzer.lucene.IKAnalyzer;

/**
 * @author huangsui.cn
 *
 */
public class TestBuck {

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Test method for {@link net.oov.identify.Buck#findTreeNode(net.oov.identify.StatusTree, java.lang.CharSequence)}.
	 * @throws IOException 
	 */
	@Test
	public final void testFindTreeNodeStatusTreeCharSequence() throws IOException {
		//TODO
	}
	
	/**
	 * Test method for {@link net.oov.identify.Buck#findTreeNode(net.oov.identify.SequenceFreqContainer, java.lang.CharSequence)}.
	 */
	@Test
	public final void testFindTreeNodeContainerCharSequence() {
		
		StringReader sr = new StringReader("专柜正品新款 达芙妮\n日本原装四色最新限量版三线系列硅胶法藤项环 法藤项环 保健钛项圈 ");
		IKAnalyzer ik = new IKAnalyzer();
		
		SequenceFreqContainerFactory cf = new SequenceFreqContainerFactory();
		SequenceFreqContainer sfc = new SequenceFreqContainer(SequenceFreqContainer.LOAD_METHOD_FORWARD,5);
		
		TokenStream ts = ik.tokenStream("product name", sr);
		
		cf.addRawCharSequence(sfc, ts);
		OI.wl(sfc.toString());
		
		Buck buck = new Buck(sfc.getDicForward());
		Assert.assertEquals(new Character('藤'), buck.findTreeNode("法藤").getKey());
		Assert.assertEquals(new Character('环'), buck.findTreeNode("法藤项环").getKey());
		
	}

}
